package com.shop2cn.iapi.member.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.member.parameter.CreateMemberBean;
import com.shop2cn.iapi.member.parameter.ReceiveDeleteUserBean;
import com.shop2cn.iapi.member.service.ReceiveDeleteUserCall;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.GodMemberService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godmember.Member;
import com.ymttest.database.sqlwapper.godmember.GodMemberWapper;
import com.ymttest.utils.TestDataManager;
/**
*根据手机号查询电铺会员
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_ReceiveDeleteUser{
	private static ReceiveDeleteUserBean ReceiveDeleteUserBean;
	private static ReceiveDeleteUserCall ReceiveDeleteUserCall;
	private static Integer shopid ;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("删除会员用户");
		try {
			shopid= GodmchManageCallService.CreateSellerMch();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		ReceiveDeleteUserBean=new ReceiveDeleteUserBean();
		ReceiveDeleteUserCall=new ReceiveDeleteUserCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(ReceiveDeleteUserCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReceiveDeleteUser_001() {
		Logger.start(true,"删除会员用户成功");
		try {
			//创建一个新会员
			UserCreateBean usercreateBean = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(usercreateBean);
			CreateMemberBean createMem = GodMemberService.initCreateMemberBean(shopid,userId,usercreateBean.getOpenId());
			createMem.setOpenId(usercreateBean.getOpenId());
			String memid = GodMemberService.creatememberCall(createMem);
			String mobile=TestDataManager.getPhoneNum();
			GodMemberService.bindMobile(shopid, userId, mobile);
			ReceiveDeleteUserBean.setUserId(userId);
			ReceiveDeleteUserCall.setData(ReceiveDeleteUserBean);
			ReceiveDeleteUserCall.callService();			
			Logger.verifyEquals("ok", ReceiveDeleteUserCall.getReturnData(), "验证返回");
			GodMemberWapper GodMemberWapper=new GodMemberWapper();
			Member mem = GodMemberWapper.selectMemberByMemberid(memid).get(0);
			Logger.debug(FormatUtil.beanToGSONString(mem));
			Logger.verifyIsNull(mem.getMobile(), "删除用户手机号为null");
			Logger.verifyIsNull(mem.getOpenId(), "删除用户openid为null");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}